/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.DragonPokerClient.Thread.ClientRequest;


import java.util.ArrayList;
import org.Comunicator.Element;
import org.Comunicator.Message;
import org.DragonPokerClient.Classes.Room;
import org.DragonPokerClient.Client;


/**
 *
 * @author davide
 */
public class RoomsReplyRequest extends GenericClientRequest{
    private Client client;
    public RoomsReplyRequest(Client c) {
        client = c;
    }
    
    @Override
    public void processRequest(Message message) {
        System.out.println("CLIENT-RoomsReply");
        ArrayList<Room> alr = new ArrayList<Room>();
        for(Element e: message.getParameters()){
            ArrayList a = (ArrayList) e.getValue();
            Room r = new Room();
            r.setName((String) a.get(1));
            r.setId((Integer) a.get(0));
            alr.add(r);
        }
        System.out.println(alr);
        client.getHomegui().prepareTable(alr);

//                boolean reply = (Boolean)message.getParameters().get("Reply");
//        if(reply == true){
//            Login l = client.getLogingui();
//            l.dispose();
//            Home h = client.startHome();
//            h.prepareTable();
//            h.setVisible(reply);
//        }
    }

    @Override
    public boolean isToProcessing(Message message) {
        if("RoomsReply".equals(message.getAction()) == true)
            return true;
        return false;
    }

}
